package com.yc.abc.servlet;

import java.io.IOException;	
import java.io.PrintWriter;

import com.yc.tomcat.core.HttpServlet;
import com.yc.tomcat.core.ServletRequest;
import com.yc.tomcat.core.ServletResponse;
import com.yc.tomcat.core.Session;

public class LoginServlet extends HttpServlet{
	@Override
	public void doGet(ServletRequest request, ServletResponse response) {
		doPost(request, response);
	}

	@Override
	public void doPost(ServletRequest request, ServletResponse response) {
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		String tel = request.getParameter("tel");
		
		Session session = request.getSession();
		session.setAttribute("name", name);
		
		System.out.println(name + "\t" + pwd + "\t" + tel);
		PrintWriter out = null;
		try {
			out = response.getWriter();
			out.print("name=" + name + " pwd=" + pwd + " tel=" + tel);
			out.flush();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}
	
}
